package com.corona.game;

import com.corona.Game;

/* compiled from: Action.java */
/* access modifiers changed from: package-private */
/* loaded from: pokewilds.jar:com/pkmngen/game/CallMethod.class */
public class CallMethod extends Action {
    Object object;
    String method;
    Object[] params;
    Class<?>[] paramTypes;

    public CallMethod(Object object, String method, Class<?>[] paramTypes, Object[] params, Action nextAction) {
        super(new Object[0]);
        this.object = object;
        this.method = method;
        this.params = params;
        this.paramTypes = paramTypes;
        this.nextAction = nextAction;
    }

    public CallMethod(Object object, String method, Object[] params, Action nextAction) {
        super(new Object[0]);
        this.object = object;
        this.method = method;
        this.params = params;
        this.nextAction = nextAction;
        this.paramTypes = new Class[params.length];
        for (int i = 0; i < params.length; i++) {
            this.paramTypes[i] = params[i].getClass();
            if (this.paramTypes[i].getName().equals("java.lang.Float")) {
                this.paramTypes[i] = Float.TYPE;
            } else if (this.paramTypes[i].getName().equals("java.lang.Integer")) {
                this.paramTypes[i] = Integer.TYPE;
            } else if (this.paramTypes[i].getName().equals("java.lang.Boolean")) {
                this.paramTypes[i] = Boolean.TYPE;
            } else if (this.paramTypes[i].getName().equals("java.lang.Long")) {
                this.paramTypes[i] = Long.TYPE;
            } else if (this.paramTypes[i].getName().equals("java.lang.Double")) {
                this.paramTypes[i] = Double.TYPE;
            }
        }
    }

    @Override // com.corona.game.Action
    public void step(Game game) {
        try {
            this.object.getClass().getMethod(this.method, this.paramTypes).invoke(this.object, this.params);
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (IllegalArgumentException e2) {
            e2.printStackTrace();
        } catch (NoSuchMethodException e3) {
            e3.printStackTrace();
        } catch (SecurityException e4) {
            e4.printStackTrace();
        } catch (Exception e5) {
            e5.printStackTrace();
        }
        game.actionStack.remove(this);
        game.insertAction(this.nextAction);
    }
}
